<?php
require_once("vnpay/libs/nusoap.php");
require_once("config.php");
require_once("functions.php");

echo '<p>1111111111111111111111111111</p>';

global $conf;
$sqlSelect = "Select * From tbl_sms_mo Order By mo_id Desc Limit 10";
$con = mysql_connect($conf['db_host'], $conf['db_user'], $conf['db_pass']);
mysql_select_db($conf['db_name']);	
$query=mysql_query($sqlSelect);
if(mysql_num_rows($query) > 0)
{
	while($row=mysql_fetch_array($query))	
	{
		$SeqNo = $row['mo_id'];
		$destination = $row['phone'];
		$sendfrom = $row['sendfrom'];
		$keywordname = $row['keywordname'];
		$outcontent = "test dich vu AZ Server";
			
		$flag = "1";		
		$total = "1";
		$type = "0";
		
		//$result = sendmt($seqno, $sendfrom, $destination, $keywordname, $outcontent, $flag, $total, $type);	
		echo '<p>========================================================</p>';
		//echo '<p>'.print_r($result, true).'</p>';
	}
}
else
{
	echo '<p>1111111111111111111111111111</p>';
}
//Send Message
function sendmt($seqno, $sendfrom, $destination, $keywordname, $outcontent, $flag, $total, $type)
{

	$client = new nusoap_client('http://112.78.7.141:1500/MVASCONTENT/MTSend.asmx?WSDL', true);
	$err = $client->getError();
	if ($err) {
		// Display the error
		echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
		exit;
		// At this point, you know the call that follows will fail
	}
	
	$client->soap_defencoding = 'UTF-8';
	$secretcode = "123456";
	$param = array (
			"Destination" => $destination, 
			"SendFrom" => $sendfrom,
			"KeywordName" => $keywordname,
			"OutContent" => $outcontent,
			"ChargingFlag" => $flag,
			"MOSeqNo" => $seqno,
			"TotalMessage" => $total,
			"ContentType" => $type,
			"SecretCode" => $secretcode,
		);
	$result = $client->call('SendMT', $param);
	$return $result['returnsms'];
}
?>